<?php

namespace app\admin\controller;
class Domain extends base
{

    public function _initialize()
    {
    }

    public function index()
    {

        $domain = $this->request->post();
        if($this->request->isPost()&&!empty($domain['dns'])&&!empty($domain['ext'])){
            $domain_name = null;
            //遍历所有的域名
            foreach ($domain['ext'] as $datakey=>$value) {
                //组合域名
                $dns = $domain['dns'] . "." . $value;

                //查询：
                $domain_name[$datakey]['name'] =$dns;
                $do = "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" . $dns;
                $xml_data = file_get_contents($do);
                $result_arr = (array)simplexml_load_string($xml_data);

                $original = $result_arr['original'];

                $status = substr($original, 0, 3);

                if ($status == "210") {

                    $domain_name[$datakey]['value']= "：<font color='green'>恭喜您,可以注册</font>";

                } else if ($status == "211") {

                    $domain_name[$datakey]['value']= "：<font color='red'>已经注册</font>";

                } else if ($status == "212") {

                    $domain_name[$datakey]['value']= "：<font color='red'>参数错误</font>";

                }
            }
            $this->assign('domain_name',$domain_name);
        }
        return $this->fetch();
    }



}
